<?php

class WeatherController extends CController
{
	public function actionIndex()
	{
		$this->setPageTitle('Погода');
		
		$records = null;
		$count   = null;
		
		$Weather = new Weather();
		$dataObj = $Weather->findWeatherInCities(false);
		
		foreach ($dataObj as $item) {
			$records[$item->cityTitle] = $item->attributes;
		}
		
		$count = count($records);
		
		$this->render('list', array(
			'cities' => $records,
			'count'  => $count 
		));
		
	}
	
	public function actionGetdata()
	{
		$Weather = new Weather();
		
		if (array_key_exists('key', $_GET) && $Weather->checkAccess($_GET['key'])) {
			$Weather->updateData();
		}
		
		die();
	}
}